﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Data;
using padnug.Domain;
using PadnugRepositoryInterfaces;
using PadnugRepository;
using PadnugService;

namespace padnug
{
    public class PadnugMembershipProvider : SqlMembershipProvider 
    {
        private IPadnugMembership repository;
        private IPadnugMembershipService svc;
        public override bool RequiresUniqueEmail
        {
            get
            {
                return true;
            }
        }

        public PadnugMembershipProvider()
        {
            repository = new PadnugMembership();
            svc = new PadnugMembershipService(repository);
        }

        public PadnugMembershipProvider(IPadnugMembership membership)
        {
            svc = new PadnugMembershipService(membership);
        }

        public new bool ValidateUser(string userName,string password)
        {
            return svc.ValidateUser(userName, password);
        }

        public bool CreateUser(PadnugUser padnugUser)
        {
            return svc.CreateUser(padnugUser);
        }

        public void UpdateUser(PadnugUser padnugUser)
        {
            svc.UpdateUser(padnugUser);
        }

        public override bool DeleteUser(string username, bool deleteAllRelatedData)
        {
            return svc.DeleteUser(username, deleteAllRelatedData);
        }

        public PadnugUser GetUser(string username, string password)
        {
            return svc.GetUser(username, password);
        }

        public override bool ChangePassword(string userName, string oldPassword, string newPassword)
        {
            return svc.ChangePassword(userName, oldPassword, newPassword);
        }
        
    }
}
